package com.jason.quectel;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;

/**
 * @author：Jason
 * @date：2022/3/9 09:37
 * @email：1129847330@qq.com
 * @description:
 */
public class ThreadPoolDemo {
    public static void main(String[] args) {
        int i = Runtime.getRuntime().availableProcessors();
        ExecutorService fixedThreadPool = Executors.newFixedThreadPool(i * 2 + 1);
        ExecutorService cachedThreadPool = Executors.newCachedThreadPool();
        ExecutorService singleThreadExecutor = Executors.newSingleThreadExecutor();
        ScheduledExecutorService scheduledExecutorService = Executors.newScheduledThreadPool(i);
        scheduledExecutorService.scheduleAtFixedRate(new Runnable() {
            @Override
            public void run() {
                System.out.println("scheduled");
            }
        }, 1000, 1000, TimeUnit.MILLISECONDS);
        //fixedThreadPool.execute(new Runnable() {
        //    @Override
        //    public void run() {
        //        System.out.println(Thread.currentThread().getName());
        //        fixedThreadPool.shutdown();
        //    }
        //});
    }
}